import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/4/6 19:00
 */

public class Solution {
    int[] ret;
    int[] index;//标记原始下标
    int[] tmpIndex;//用于合并时的数组
    int[] tmpNum;
    public List<Integer> countSmaller(int[] nums){
        int n = nums.length;
        ret = new int[n];
        index = new int[n];
        tmpIndex = new int[n];
        tmpNum = new int[n];

        //初始化index数组
        for (int i = 0; i < n; i++) {
            index[i] = i;
        }

        Mergesort(nums,0,n - 1);
        List<Integer> res = new ArrayList<>();
        for(int x : ret)
            res.add(x);
        return res;
    }

    private void Mergesort(int[] nums, int left, int right) {
        if(left >= right) return;

        //根据中间元素划分区间
        int mid = (left + right) / 2;

        //处理左右区间
        Mergesort(nums,left,mid);
        Mergesort(nums,mid + 1,right);

        //合并
        int p1 = left,p2 = mid + 1,i = 0;
        while(p1 <= mid && p2 <= right){//降序
            if(nums[p1] <= nums[p2]){
                tmpNum[i] = nums[p2];
                tmpIndex[i++] = index[p2++];
            } else {
                ret[index[p1]] += right - p2 + 1;
                tmpNum[i] = nums[p1];
                tmpIndex[i++] = index[p1++];
            }
        }

        //处理剩余的排序
        while(p1 <= mid){
            tmpNum[i] = nums[p1];
            tmpIndex[i++] = index[p1++];
        }
        while(p2 <= right){
            tmpNum[i] = nums[p2];
            tmpIndex[i++] = index[p2++];
        }
        for (int j = left; j <= right; j++) {
            nums[j] = tmpNum[j - left];
            index[j] = tmpIndex[j - left];
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int len = in.nextInt();
            int[] nums = new int[len];
            for (int i = 0; i < len; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(solution.countSmaller(nums));
        }
    }
}